/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.knolle.vistas;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.openide.DialogDescriptor;
import org.openide.DialogDisplayer;
import org.openide.awt.ActionRegistration;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionReferences;
import org.openide.awt.ActionID;
import org.openide.util.NbBundle.Messages;

@ActionID(category = "File",
id = "org.knolle.vistas.AgregarActividadesAction")
@ActionRegistration(displayName = "#CTL_AgregarActividadesAction")
@ActionReferences({
    @ActionReference(path = "Menu/File", position = 1450, separatorBefore = 1425),
    @ActionReference(path = "Shortcuts", name = "O-A")
})
@Messages("CTL_AgregarActividadesAction=AgregarActividades")
public final class AgregarActividadesAction implements ActionListener {

    PanelAgregarActividades2 atp;
    DialogDescriptor dd;
    
    
    public AgregarActividadesAction (){
    
    }
    public AgregarActividadesAction (String nombre){
    
    }
    
    
    @Override
    public void actionPerformed(ActionEvent e) {
        // TODO implement action body
            
        if (e.getSource() == DialogDescriptor.OK_OPTION ){
            try {
                if (atp.guardar()){
                    dd.setClosingOptions(null);
                }
            }
            catch (Exception e1) {}
        }
        else if (e.getSource() == DialogDescriptor.CANCEL_OPTION ) {
           dd.setClosingOptions(null);
        }        
                
        else if (e.getActionCommand().equals("AgregarActividades")){
            atp=new PanelAgregarActividades2(null, null);
            dd = new DialogDescriptor(atp, "Agregar Actividad Seleccionando Campaña y Lote", true, this);
            dd.setClosingOptions(new Object[] {});
            DialogDisplayer.getDefault().notifyLater(dd);
        }   
                
    }
}
